<?php

namespace App\Services\Admin;

use App\Models\Goods as GoodsModel;

class Goods extends Base
{
    public static function lists()
    {
        $input = request()->all();

        $where = [];

        if(!empty($input['sear_value'])){
            $where[] = ['goods_name','like','%'.$input['sear_value'].'%'];
        }

        if(!empty($input['is_opend'])){
            $where[] = ['is_opend', $input['is_opend']];
        }

        return (new GoodsModel)->where($where)->orderBy('id', 'desc')->paginate(15);
    }

    public static function info($id)
    {
        return (new GoodsModel)->where('id', $id)->first();
    }

    public static function add($param = [])
    {
        return (new GoodsModel)->insert($param);
    }

    public static function edit($id , $param=[])
    {
       // dd($param);
        return (new GoodsModel)->where('id',$id)->update($param);
    }

    public static function del($id)
    {
        return (new GoodsModel)->where('id', $id)->delete();
    }
}
